home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mc51bugs / q32514 < prev    next >
Text File  |  1988-07-20  |  1KB  |  47 lines

  1. Q32514 Getw Does Not Return EOF with One Byte in File
  2. C Compiler
  3. 5.10   | 5.10
  4. MS-DOS | OS/2
  5.  
  6. Summary:
  7.    An attempt to read the last byte from a file using the run-time
  8. function getw() may fail. The function incorrectly returns a
  9. corruption of the last byte and one byte of the EOF value.
  10.    The following program illustrates this problem:
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14.  
  15. FILE *stream;
  16. int i;
  17.  
  18. main()
  19. {
  20.   stream = fopen("t.in", "wb");
  21.   i = putc('a',stream);
  22.   if ( i != (int)'a' )
  23.     {
  24.     printf("Write failure, test is invalid\n");
  25.     fclose(stream);
  26.     }
  27.   else
  28.     {
  29.     fclose(stream);
  30.     stream = fopen("t.in", "rb");
  31.     i = getw(stream);
  32.     if ( i == EOF )
  33.       printf("passed\n");
  34.     else
  35.       printf("failed\n");
  36.     }
  37. }
  38.  
  39.    Microsoft has confirmed this to be a problem in Version 5.10
  40. of the C compiler. We are researching this problem and will post new
  41. information as it becomes available.
  42.  
  43.  
  44.  
  45. Keywords:  buglist5.10 qfbv
  46. Updated  88/07/21 03:19
  47.